import request from '@/utils/request'

import type { form ,password} from '@/config/adminInterface'
// 登录请求
export const loginApi = (info : form) => request.post('login',{...info})

// 获取管理员信息和权限
export const getInfoApi = () => request.post('getinfo')

// 退出登录
export const logoutApi = () => request.post('logout')

// 修改密码
export const updatePasswordApi = (info:password) => request.post('updatepassword',{...info})

// 增加管理员
export const addAdminApi = (username:string,password:string,role_id:number,status:number,avatar?:string) => request.post('manager',{username,password,role_id,status,avatar})

// 修改管理员
export const updataAdminApi = (id:number,username:string,password:string,role_id:number,status:number,avatar?:string) => request.post(`manager/${id}`,{username,password,role_id,status,avatar})

// 管理员列表
export const adminListApi = (page:number,limit?:number,keyword?:string) => request.get(`manager/${page}`,{params:{limit,keyword}})

// 修改管理员状态
export const updataAdminStateApi = (id:number,status:number) => request.post(`manager/${id}/update_status`,{status})

// 删除管理员
export const removeAdminApi = (id:number) => request.post(`manager/${id}/delete`)